import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import HomeView from "../views/HomeView.vue";
import LoginView from "@/views/user/LoginView.vue";
import RegisterView from "@/views/user/RegisterView.vue";
import AdminView from "@/views/admin/AdminView.vue";
import NotFountView from "@/views/NotFountView.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "home",
    component: HomeView,
    meta: {
      title: "首页",
    },
  },
  {
    path: "/user/login",
    name: "login",
    component: LoginView,
    meta: {
      title: "登录",
    },
  },
  {
    path: "/user/register",
    name: "register",
    component: RegisterView,
    meta: {
      title: "注册",
    },
  },
  {
    path: "/admin/userManage",
    name: "userManage",
    component: AdminView,
    meta: {
      title: "用户管理",
    },
  },
  {
    path: "/:pathMatch(.*)*",
    name: "404",
    component: NotFountView,
    meta: {
      title: "404",
    },
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
